package com.jwaoo.mobile.view.register;

import android.content.Intent;
import android.os.Bundle;

import com.dx.as.UI;
import com.dx.as.common.CommonUtils;
import com.dx.as.common.FragmentUtils;
import com.jwaoo.mobile.R;
import com.jwaoo.mobile.view.register.fragment.AccountFragment;
import com.jwaoo.mobile.view.register.fragment.CountryFragment;
import com.jwaoo.mobile.view.register.fragment.HeadFragment;
import com.jwaoo.mobile.view.register.fragment.NickNameFragment;
import com.jwaoo.mobile.view.register.fragment.SexFragment;
import com.jwaoo.mobile.view.register.fragment.SuccessFragment;
import com.jwaoo.mobile.view.setting.fragment.SettingFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by jwaoo on 2017/7/31.
 */

public class RegisterActivity extends UI implements IParamListener{
    private Map<String,Object> map = new HashMap<>();

    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_container);
        AccountFragment fragment1 = new AccountFragment();
        FragmentUtils.putDefaultFragment(this,R.id.register_container,fragment1);
        setToolbar(null);
    }


    @Override
    public void saveEmail(String email,String password) {
        map.put("account",email);
        map.put("password",password);
        CommonUtils.saveAccount(email);
    }

    @Override
    public void saveCuntry(String area) {
        map.put("area",area);
    }

    @Override
    public void saveAvatarUrl(String url) {
        map.put("avatar",url);
    }

    @Override
    public void saveNickName(String nickName) {
        map.put("nickname",nickName);
    }

    @Override
    public void saveAge(String age) {
        map.put("birthday",age);
    }

    @Override
    public Map getParamMap() {
        return map;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        FragmentUtils.clearFragmentByClass(CountryFragment.class);
        FragmentUtils.clearFragmentByClass(AccountFragment.class);
        FragmentUtils.clearFragmentByClass(SexFragment.class);
        FragmentUtils.clearFragmentByClass(SuccessFragment.class);
        FragmentUtils.clearFragmentByClass(HeadFragment.class);
        FragmentUtils.clearFragmentByClass(NickNameFragment.class);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        FragmentUtils.getCurrentFragment().onActivityResult(requestCode, resultCode, data);
    }


}
